package com.skt.exception;

import lombok.Getter;

@Getter
public enum OrderErrorCode implements ErrorCode {

    // ========== 通用订单错误 (20xxx) ==========
    ORDER_NOT_FOUND(20001, "订单不存在"),
    ORDER_ACCESS_DENIED(20002, "无权访问该订单"),
    ORDER_OPERATION_NOT_ALLOWED(20003, "当前订单状态不允许此操作"),

    // ========== 租户创建订单 (201xx) ==========
    CREATE_ORDER_FAILED(20101, "创建订单失败"),
    INVALID_RENTAL_DATE_RANGE(20102, "租赁日期范围无效"),
    COSTUME_NOT_AVAILABLE(20103, "服装商品不可用或已下架"),
    INSUFFICIENT_INVENTORY(20104, "库存不足"),
    USER_ADDRESS_NOT_FOUND(20105, "收货地址不存在"),
    COSTUME_PRICE_CHANGED(20106, "服装价格已变动，请重新下单"),
    DUPLICATE_ORDER_DETECTED(20107, "检测到重复下单请求"),

    // ========== 租户取消订单 (202xx) ==========
    CANCEL_ORDER_FAILED(20201, "取消订单失败"),
    ORDER_CANNOT_BE_CANCELLED(20202, "当前订单状态不可取消"),
    ORDER_ALREADY_CANCELLED(20203, "订单已被取消"),
    ORDER_ALREADY_COMPLETED(20204, "订单已完成，无法取消"),
    CANCEL_WINDOW_EXPIRED(20205, "已超过可取消时间"),

    // ========== 租户查询订单 (203xx) ==========
    QUERY_ORDER_LIST_FAILED(20301, "查询订单列表失败"),
    INVALID_ORDER_STATUS_FILTER(20302, "订单状态筛选值无效"),
    ORDER_DETAIL_QUERY_FAILED(20303, "查询订单详情失败"),
    ORDER_NO_INVALID_FORMAT(20304, "订单编号格式无效"),
    ORDER_NOT_OWNED_BY_USER(20305, "该订单不属于当前用户"),

    // ========== 商家发货订单 (204xx) ==========
    SHIP_ORDER_FAILED(20401, "发货操作失败"),
    ORDER_CANNOT_BE_SHIPPED(20402, "当前订单状态不可发货"),
    ORDER_ALREADY_SHIPPED(20403, "订单已发货，不可重复操作"),
    ORDER_NOT_PAID_YET(20404, "订单未支付，无法发货"),

    // ========== 商家确认归还订单 (205xx) ==========
    RETURN_ORDER_FAILED(20501, "确认归还订单失败"),
    ORDER_CANNOT_BE_RETURNED(20502, "当前订单状态不可确认归还"),
    ORDER_ALREADY_RETURNED(20503, "订单已归还，不可重复操作"),
    ORDER_NOT_PICKED_UP_YET(20504, "订单尚未取货，无法确认归还"),

    // ========== 参数校验错误 (208xx) ==========
    MISSING_REQUIRED_PARAMETER(20801, "缺少必要参数"),
    INVALID_PARAMETER_FORMAT(20802, "参数格式无效"),

    // --- 日期相关 ---
    START_DATE_REQUIRED(20803, "租赁开始日期不能为空"),
    END_DATE_REQUIRED(20804, "租赁结束日期不能为空"),
    START_DATE_BEFORE_TODAY(20805, "租赁开始日期不能早于今天"),
    END_DATE_NOT_AFTER_START(20806, "租赁结束日期必须晚于开始日期"),
    RENTAL_DURATION_TOO_SHORT(20807, "租赁时长至少为1天"),
    RENTAL_DURATION_TOO_LONG(20808, "租赁时长不能超过30天"),
    START_DATE_RANGE_INVALID(20809, "租赁开始日期范围无效：开始日期From不能晚于To"),
    END_DATE_RANGE_INVALID(20810, "租赁结束日期范围无效：结束日期From不能晚于To"),

    // --- ID 相关 ---
    USER_ID_INVALID(20809, "用户ID无效"),
    MERCHANT_ID_INVALID(20810, "商家ID无效"),
    COSTUME_ID_INVALID(20811, "服装商品ID无效"),
    ADDRESS_ID_INVALID(20812, "收货地址ID无效"),
    ORDER_ID_INVALID(20813, "订单ID无效"),

    // --- 数量与金额（防前端传入）---
    QUANTITY_INVALID(20814, "商品数量无效"),
    COSTUME_PRICE_INVALID(20815, "服装日租金无效"),
    TOTAL_DAYS_PROVIDED(20816, "租赁天数不可由客户端指定"),
    ORDER_NO_PROVIDED(20817, "订单编号不可由客户端指定"),
    STATUS_PROVIDED(20818, "订单状态不可由客户端指定"),

    // --- 其他 ---
    REMARK_TOO_LONG(20819, "订单备注长度不能超过200字符"),
    ORDER_ITEMS_EMPTY(20820, "订单商品列表不能为空"),

    // ========== 系统/风控 (209xx) ==========
    ORDER_SERVICE_UNAVAILABLE(20901, "订单服务暂不可用，请稍后重试"),
    CONCURRENT_ORDER_CREATION(20902, "检测到并发创建订单，请稍后重试"),
    ORDER_LOCK_ACQUIRE_FAILED(20903, "系统繁忙，获取订单锁失败");

    private final int code;
    private final String message;

    OrderErrorCode(int code, String message) {
        this.code = code;
        this.message = message;
    }
}